﻿using System;
using System.Collections.Generic;
using System.Text;
using OC.Common.Interface;
using System.Collections;
using OC.Common.Entity;

namespace OC.Logic
{
    class ProcessConfigLogic:IProcessConfig
    {
        public bool Exists(string ProcessName, string StepName)
        {
            ProcessConfigEntity processConfig = GetProcessConfig(ProcessName, StepName);
            return processConfig != null ? true : false;
        }

        public ProcessConfigEntity GetProcessConfig(string ProcessName, string StepName)
        {
            Hashtable table = new Hashtable();
            table.Add("process_name", ProcessName);
            table.Add("step_name", StepName);
            ProcessConfigEntity processConfig = DataHelper.Instance().Get<ProcessConfigEntity>("ProcessConfigLogic_GetProcessConfig", table);
            return processConfig;
        }

        public void InsertProcessConfig(ProcessConfigEntity entity)
        {
            Hashtable table = new Hashtable();
            table.Add("CONFIG_ID", entity.CONFIG_ID);
            table.Add("PROCESS_NAME", entity.PROCESS_NAME);
            table.Add("STEP_NAME", entity.STEP_NAME);
            table.Add("DEPARTMENT_ID", entity.DEPARTMENT_ID);
            table.Add("FORM_VIEW", entity.FORM_VIEW);
            table.Add("FORM_VIEWUSER", entity.FORM_VIEWUSER);
            table.Add("ATTACHMENT_DOWNLOAD", entity.ATTACHMENT_DOWNLOAD);
            table.Add("ATTACHMENT_DOWNLOADUSER", entity.ATTACHMENT_DOWNLOADUSER);
            table.Add("APPROVAL_SAMELEVEL", entity.APPROVAL_SAMELEVEL);
            table.Add("APPROVAL_SAMELEVEL_XMLPATHID", entity.APPROVAL_SAMELEVEL_XMLPATHID);
            table.Add("APPROVAL_TYPE", entity.APPROVAL_TYPE);
            table.Add("APPROVAL_TYPE_XMLPATH_ID", entity.APPROVAL_TYPE_XMLPATH_ID);
            table.Add("APPROVAL_MAXLEVEL", entity.APPROVAL_MAXLEVEL);
            table.Add("APPROVAL_MINLEVEL", entity.APPROVAL_MINLEVEL);
            table.Add("APPROVAL_DEPARMENT_ID", entity.APPROVAL_DEPARMENT_ID);
            table.Add("DEPARMENT_ID", entity.DEPARMENT_ID);
            table.Add("DEPARTMENT_ORDER", entity.DEPARTMENT_ORDER);
            table.Add("IS_FORWARD", entity.IS_FORWARD);
            table.Add("FORWARD_DEPARTMENT_ID", entity.FORWARD_DEPARTMENT_ID);
            table.Add("FORWARD_TIMES", entity.FORWARD_TIMES);
            table.Add("HELP_CONTENT", entity.HELP_CONTENT);
            table.Add("CREATE_DATE", entity.CREATE_DATE);
            table.Add("CREATE_BY", entity.CREATE_BY);
            table.Add("UPDATE_DATE", entity.UPDATE_DATE);
            table.Add("UPDATE_BY", entity.UPDATE_BY);
            table.Add("IS_ACTIVE", entity.IS_ACTIVE);
            DataHelper.Instance().Insert("ProcessConfigLogic_InsertProcessConfig", table);
        }

        public void UpdateProcessConfig(ProcessConfigEntity entity)
        {
            Hashtable table = new Hashtable();
            table.Add("PROCESS_NAME", entity.PROCESS_NAME);
            table.Add("STEP_NAME", entity.STEP_NAME);
            table.Add("DEPARTMENT_ID", entity.DEPARTMENT_ID);
            table.Add("FORM_VIEW", entity.FORM_VIEW);
            table.Add("FORM_VIEWUSER", entity.FORM_VIEWUSER);
            table.Add("ATTACHMENT_DOWNLOAD", entity.ATTACHMENT_DOWNLOAD);
            table.Add("ATTACHMENT_DOWNLOADUSER", entity.ATTACHMENT_DOWNLOADUSER);
            table.Add("APPROVAL_SAMELEVEL", entity.APPROVAL_SAMELEVEL);
            table.Add("APPROVAL_SAMELEVEL_XMLPATHID", entity.APPROVAL_SAMELEVEL_XMLPATHID);
            table.Add("APPROVAL_TYPE", entity.APPROVAL_TYPE);
            table.Add("APPROVAL_TYPE_XMLPATH_ID", entity.APPROVAL_TYPE_XMLPATH_ID);
            table.Add("APPROVAL_MAXLEVEL", entity.APPROVAL_MAXLEVEL);
            table.Add("APPROVAL_MINLEVEL", entity.APPROVAL_MINLEVEL);
            table.Add("APPROVAL_DEPARMENT_ID", entity.APPROVAL_DEPARMENT_ID);
            table.Add("DEPARMENT_ID", entity.DEPARMENT_ID);
            table.Add("DEPARTMENT_ORDER", entity.DEPARTMENT_ORDER);
            table.Add("IS_FORWARD", entity.IS_FORWARD);
            table.Add("FORWARD_DEPARTMENT_ID", entity.FORWARD_DEPARTMENT_ID);
            table.Add("FORWARD_TIMES", entity.FORWARD_TIMES);
            table.Add("HELP_CONTENT", entity.HELP_CONTENT);
            table.Add("UPDATE_DATE", entity.UPDATE_DATE);
            table.Add("UPDATE_BY", entity.UPDATE_BY);
            table.Add("IS_ACTIVE", entity.IS_ACTIVE);
            DataHelper.Instance().Update("ProcessConfigLogic_UpdateProcessConfig", table);

        }
    }
}
